package com.gali.juc;

import org.openjdk.jol.info.ClassLayout;

import java.util.concurrent.TimeUnit;

/**
 * @Auther: gali
 * @Date: 2022-08-25 17:26
 * @Description:
 */
public class SynchronizedUpDemo {
    private static Object o =new Object();
    public static void main(String[] args) {

//        System.out.println("十进制："+o.hashCode());
//        System.out.println("十六进制："+Integer.toHexString(o.hashCode()));
//        System.out.println("二进制："+Integer.toBinaryString(o.hashCode()));
        //System.out.println(ClassLayout.parseInstance(o).toPrintable());

        System.out.println("-------------------");
        new Thread(()->{
            synchronized (o){
                System.out.println(ClassLayout.parseInstance(o).toPrintable());
            }
        },"a").start();
        new Thread(()->{
            synchronized (o){
                System.out.println(ClassLayout.parseInstance(o).toPrintable());
            }
        },"b").start();
    }
}
